//长度最小的子数组 力扣209
//滑动窗口
class Solution {
public:
	int minSubArrayLen(int t, vector<int>& a) {
		int sum = 0;
		int ans = a.size()+1;
		for(int l = 0,r = 0; r < a.size(); r++)
		{
			sum += a[r];
			while(sum >= t)
			{
				ans = min(ans,r-l+1);
				sum -= a[l];
				l++;
				
			}
		}
		if(ans <= a.size()) return ans;
		return 0;
	}
};
